﻿Imports System.Text.RegularExpressions
Public Class fcursos 

    Private Sub CursoBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles CursoBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.CursoBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbSolucionesEducativasDataSet)

    End Sub

    Private Sub fcursos_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbSolucionesEducativasDataSet.area' table. You can move, or remove it, as needed.
        Me.AreaTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.area)
        'TODO: This line of code loads data into the 'DbSolucionesEducativasDataSet.curso' table. You can move, or remove it, as needed.
        Me.CursoTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.curso)

    End Sub

    Function Habilitar()
        LookUpEdit1.Enabled = True
        cmbCurso.Enabled = True
        CurdescripcionTextBox.ReadOnly = False
        Return 0
    End Function

    Function DesHabilitar()
        LookUpEdit1.Enabled = False
        cmbCurso.Enabled = False
        CurdescripcionTextBox.ReadOnly = True
        Return 0
    End Function

    Private Sub SimpleButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardar.Click
        CursoBindingNavigatorSaveItem.PerformClick()
        DesHabilitar()
    End Sub

    Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles agregar.Click
        BindingNavigatorAddNewItem.PerformClick()
        Habilitar()
    End Sub

    Private Sub SimpleButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles modificar.Click
        Habilitar()
    End Sub

    Private Sub SimpleButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancelar.Click
        DesHabilitar()
        Me.CursoTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.curso)
    End Sub

    Private Sub AreidTextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles AreidTextBox.TextChanged
        LookUpEdit1.ItemIndex = Val(AreidTextBox.Text)
    End Sub

    Function DescCurso()
        Try
            Dim descripcion As String
            descripcion = cmbCurso.SelectedItem.ToString() + " de " + LookUpEdit1.Text
            CurdescripcionTextBox.Text = descripcion
        Catch ex As Exception

        End Try
        Return 0
    End Function


    Private Sub cmbCurso_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbCurso.SelectedIndexChanged
        DescCurso()
    End Sub

    Private Sub SimpleButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imprimir.Click
        ' Check whether the GridControl can be previewed.
        If Not GridControl1.IsPrintingAvailable Then
            MessageBox.Show("Error al intentar imprimir el reporte, contacte el administrador del sistema.", "Error")
            Return
        End If

        ' Opens the Preview window.
        GridControl1.ShowPrintPreview()
    End Sub

    Private Sub PanelArriba_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PanelArriba.Paint

    End Sub

    Private Sub LookUpEdit1_EditValueChanged(sender As System.Object, e As System.EventArgs) Handles LookUpEdit1.EditValueChanged
        AreidTextBox.Text = LookUpEdit1.ItemIndex
        DescCurso()
    End Sub
End Class